// 封装一个页码组件
import React from 'react'

interface IProps {
  total: number
  pageSize: number
  current: number
  onChange: (page: number) => void
}
export default function Pagesize(props: IProps) {
  const { total, pageSize, current, onChange } = props
  const pageCount = Math.ceil(total / pageSize)
  const pageArr = []
  for (let i = 1; i <= pageCount; i++) {
    pageArr.push(i)
  }
  return (
    <div className="pagesize">
      {pageArr.map((item) => {
        return (
          <span
            key={item}
            className={current === item ? 'active' : ''}
            onClick={() => onChange(item)}
          >
            {item}
          </span>
        )
      })}
    </div>
  )
}